package com.tinckay.entity.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.time.LocalDate;

import com.baomidou.mybatisplus.annotation.TableId;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;
import java.util.List;

import com.tinckay.common.constant.ProjectConstant;
import com.tinckay.common.constant.RegexConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * <p>
 *
 * </p>
 *
 * @author Jean
 * @since 2018-10-21
 */
@Data
@TableName("sys_user")
@ApiModel(value = "User对象", description = "用户信息")
public class User extends Model<User> {

    private static final long serialVersionUID = -4800080427747532249L;

    @TableId(value = "id", type = IdType.AUTO)
    @NotNull(message = "id不能为空", groups = ProjectConstant.Update.class)
    private Long id;

    @ApiModelProperty(value = "工号")
    @TableField("workNo")
    private String workNo;

    @Pattern(regexp = RegexConstant.USER_NAME, message = "账户不符合验证规则", groups = ProjectConstant.Save.class)
    @ApiModelProperty(value = "账户")
    private String username;

    @Pattern(regexp = RegexConstant.PASS_WORD, message = "密码不符合验证规则", groups = ProjectConstant.Save.class)
    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "用户姓名")
    private String name;

    @ApiModelProperty(value = "生日")
    private LocalDate birthday;

    @ApiModelProperty(value = "地址")
    private String address;

    @Pattern(regexp = RegexConstant.MOBILE_PHONE, message = "手机号码格式有误", groups = ProjectConstant.Save.class)
    @ApiModelProperty(value = "手机号码")
    private String mobile;

    @ApiModelProperty(value = "电话号码")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @Pattern(regexp = RegexConstant.ZERO_OR_ONE, message = "性别字典有误", groups = ProjectConstant.Save.class)
    @ApiModelProperty(value = "性别 0女 1男")
    private String gender;

    @ApiModelProperty(value = "备注信息")
    private String remark;

    @Pattern(regexp = RegexConstant.ZERO_OR_ONE, message = "用户字典状态有误", groups = ProjectConstant.Save.class)
    @ApiModelProperty(value = "用户状态 0锁定 1有效")
    private String status = ProjectConstant.VALID_ACCOUNT;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建人")
    private String creator;

    @ApiModelProperty(value = "上次登陆时间", hidden = true)
    private LocalDateTime lastLoginTime;

    @ApiModelProperty(hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime dataTime;

    @ApiModelProperty(value = "创建时间", hidden = true)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新时间", hidden = true)
    private LocalDateTime updateTime;

    @TableField(exist = false)
    @ApiModelProperty(hidden = true)
    private List<Role> roles;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
